<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Try it</title>
  </head>
  <body>
    <div id="div1">... Content of DIV element...</div>
    <div id="div2">
      <p>Here is some original.</p>
    </div>
    <script>
      // ---------------------------------------------------
      alert('This is my message');

      // ---------------------------------------------------
      const answer1 = confirm('Are you happy to continue?');

      // ---------------------------------------------------
      const answer2 = prompt('What is your full name?');
      const answer3 = prompt('What is yhour full name?', 'John Doe');

      // ---------------------------------------------------
      const myDiv = document.getElementById('div1');

      // ---------------------------------------------------
      const myDivContents = document.getElementById('div2').innerHTML;
      document.getElementById('div2').innerHTML =
        '<p>Here is some new text insted!</p>';

      // ---------------------------------------------------
      alert(
        "You're visited " +
          history.length +
          ' web pages in this browser session'
      );
      history.forward();
      history.go(-3);
      history.go(2);
      history.go('example.com');

      // ---------------------------------------------------
      location.reload();
      location.reload(true);

      // ---------------------------------------------------

      const myDate = new Date();
      const year = myDate.getFullYear();
      const month = myDate.getMonth();
      const date = myDate.getDate();
      const day = myDate.getDay();
      const hours = myDate.getHours();
      const minutes = myDate.getMinutes();
      const seconds = myDate.getSeconds();

      // ---------------------------------------------------
      const d1 = new Date('October 22, 1995, 10:57:22');
      const d2 = new Date(95, 10, 22);
      const d3 = new Date(95, 10, 22, 10, 57, 0);

      // ---------------------------------------------------
      const myDate2 = new Date();
      document.write(
        'Object created on day number' + myDate2.getDay() + '<br>'
      );
      myDate2.setDate(15);
      document.write(
        'After amending date to 15th, the day number is ' + myDate2.getDay()
      );

      // ---------------------------------------------------
      const myDate3 = new Date();
      document.write(
        'Created: ' +
          myDate3.toDateString() +
          ' ' +
          myDate3.toTimeString() +
          '<br>'
      );
      myDate3.setDate(myDate3.getDate() + 33);
      document.write('After adding 33 days:' + myDate3.toTimeString());

      // ---------------------------------------------------
      const myNum1 = 12.55;
      const myNum2 = 12.45;
      alert(Math.floor(myNum1));
      alert(Math.ceil(myNum2));
      alert(Math.round(myNum1));
      alert(Math.round(myNum2));

      // ---------------------------------------------------
      const ageDavid = 23;
      const ageMary = 27;
      const ageChris = 31;
      const ageSandy = 19;
      document.write(
        'The youngest person is ' +
          Math.min(ageDavid, ageMary, ageChris, ageSandy) +
          ' years old<br>'
      );
      document.write(
        'The oldest person is ' +
          Math.max(ageDavid, ageMary, ageChris, ageSandy) +
          ' years old<br>'
      );

      // ---------------------------------------------------
      function myRand(range) {
        return Math.round(Math.random() * range);
      }

      myRand(100);
    </script>
  </body>
</html>
